from typing import Optional, List
import os

AK = '2jCwbiCWReSVlPbt53f9pYhP'
SK = 'dwJ8BULLCsBMXsmtjyxNI8hkw4y0HPXq'
os.environ['QIANFAN_AK'] = AK
os.environ['QIANFAN_SK'] = SK
from langchain.memory import ChatMessageHistory
from langchain.schema import messages_from_dict, messages_to_dict

history = ChatMessageHistory()
history.add_user_message('hi!')
history.add_user_message('whats up?')
dicts = messages_to_dict(history.messages)
print(dicts)
new_messages = messages_from_dict(dicts)
print(new_messages)

